<?php
defined ( 'IN_TS' ) or die ( 'Access Denied.' );

switch ($ts) {
	
	case "" :
		
		$groupid = intval ( $_GET ['groupid'] );
		$strGroup = $new ['article']->find ( 'group', array (
				'groupid' => $groupid 
		) );
		
		// 列表
		$page = isset ( $_GET ['page'] ) ? intval ( $_GET ['page'] ) : 1;
		$url = tsUrl ( 'article', 'group', array (
				'groupid' => $groupid,
				'page' => '' 
		) );
		$lstart = $page * 15 - 15;
		
		$arrArticles = $new ['article']->findAll ( 'article', array (
				'groupid' => $groupid,
				'isaudit' => 0 
		)
			,'istop desc,addtime desc', '', $lstart . ',15' );
		
		$articleNum = $new ['article']->findCount ( 'article', array (
				
				'groupid' => $groupid,
				'isaudit' => 0 
		)
		 );
		
		$pageUrl = pagination ( $articleNum, 15, $page, $url );
		
		foreach ( $arrArticles as $key => $item ) {
			$arrArticle [] = $item;
			$arrArticle [$key]['title'] = stripslashes($item['title']);
			$arrArticle [$key] ['user'] = aac ( 'user' )->getOneUser ( $item ['userid'] );
			$arrArticle	[$key] ['abs'] = cututf8 ( t(tsDecode($item ['content'])), 0, 80 );
			$arrArticle[$key]['abs'] = cututf8 ( t(tsDecode($item ['content'])), 0, 80 );
			if(!$arrArticle[$key]['abs']){
				$img_path =getTextPhotos(tsDecode($item ['content']));
				if($img_path){
					$arrArticle[$key]['abs']='<img width="100%" src="'.$img_path[0].'">';
				}
			}
		}

		$title = $strGroup ['groupname'];
		
		// SEO优化
		$sitekey = $strGroup ['groupname'];
		$sitedesc = $strGroup ['groupname'] . ' - 文档';
		
		include template ( 'group' );
		
		break;
}